/**中小学 */
export const getChecked2 = {
    grades: (allData) => {//年级
        let grades:any[] = [], grades_pop:any[] = []
        allData.map((item,index)=>{
            if(item.hasCho == 0){
                //无选中
            }else if(item.hasCho == 1){//全选
                grades.push({gradeId:item.Info.gradeId, gradeName:item.Info.gradeName})
                grades_pop.push(item)
            }else if(item.hasCho == 2){//半选
                //暂无这种情况
            }
        })
        return {
            grades: grades, 
            grades_pop:grades_pop,
            AllChecked:(allData.filter(item2=>item2.hasCho == 1).length == allData.length)?true:false
        }
    },

    classes: (allData) => {//班级
        let grades:any[] = [], grades_pop:any[] = []
        let classes:any[] = [], classes_pop:any[] = []
        allData.map((item,index)=>{
          if(item.hasCho == 0){
            //无选中
          }else if(item.hasCho == 1){//全选
            grades.push({gradeId:item.Info.gradeId, gradeName:item.Info.gradeName})
            grades_pop.push(item)
          }else if(item.hasCho == 2){//半选
            let a = handleClasses(item,1,{classes:[],classes_pop:[]})
            classes = classes.concat(a.classes)
            classes_pop = classes_pop.concat(a.classes_pop)
          }
        })
        return {
            grades: grades, 
            grades_pop:grades_pop,
            classes:classes,
            classes_pop:classes_pop,
            AllChecked:(allData.filter(item2=>item2.hasCho == 1).length == allData.length)?true:false
        }
    },

    // identities: (item) => {
    //     let identities:any[] = [], identities_pop:any[] = []
    //     let persons:any[] = [], persons_pop:any[] = []
    //     if(item.hasCho == 0){
    //         //无选中
    //     }else if(item.hasCho == 1){//全选
    //         item.subData.map((item1,index)=>{
    //             identities.push({identityCode:item1.Info.identityCode,identityName:item1.Info.identityName})
    //             identities_pop.push(item1)
    //         })
    //         // showChoObjArr.push("全部管理员")
    //     }else if(item.hasCho == 2){//半选
    //         let a = handleAdmin(item,1,{identities:[],persons:[],identities_pop:[],persons_pop:[]})
    //         identities = identities.concat(a.identities)
    //         identities_pop = identities_pop.concat(a.identities_pop)

    //         persons = persons.concat(a.persons)
    //         persons_pop = persons_pop.concat(a.persons_pop)
    //         // showChoObjArr.push("部分管理员")
    //     }
    // }
}



//班级处理
function handleClasses(data,level,objStore){
    data.subData.map(item=>{
      if(item.hasCho == 0){
        //无选中
      }else if(item.hasCho == 1){//全选
        let obj:any = {classId:item.Info.classId, className:item.Info.className}
        if(item.Info.classType){obj.classType = item.Info.classType}
        objStore.classes.push(obj)
        objStore.classes_pop.push(item)
      }else if(item.hasCho == 2){//半选
        //年级处理暂无该情况
      }
    })
    return objStore
}
// //管理员处理
// function handleAdmin(data,level,objStore){
//     data.subData.map(item=>{
//       if(item.hasCho == 0){
//         //无选中
//       }else if(item.hasCho == 1){
//         if(level == 1){
//           objStore.identities.push({identityCode:item.Info.identityCode,identityName:item.Info.identityName})
//           objStore.identities_pop.push(item)
//         }else if(level == 2){
//           objStore.persons.push({userId:item.Info.userId,userName:item.Info.userName,photoPath:item.Info.photoPath})
//           objStore.persons_pop.push(item)
//         }
//       }else if(item.hasCho == 2){
//         this.handleAdmin(item,level+1,objStore)
//       }
//     })
//     return objStore
// }